<?php
/**
 * gcFramework
 *
 * Development framework for PHP 5 or newer
 *
 * @package		gcFramework
 * @author		Adam Martin
 * @copyright	Copyright (c) 2006
 * @license		http://www.gcFramework.com/web/license.html
 * @link		http://www.gcFramework.com
 * @since		Version 1.0
 */
 
 //instantiate class
 $security = new security;
 
 class security{
 	
 	public function security(){
 	}
 	
 	public function mkpasswd($length='7'){
 		$salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
 		srand((double)microtime()*1000000);
 		$password = "";
 		for($i=0; $i<$length; $i++){
 			$password = $password . substr($salt, rand() % strlen($salt), 1);
 		}
 		return $password;
 	}
 	
 	public function md5passwd($password){
 		if(!$password){
 			displayError(ERROR_NOPASSWORD);	
 		}
 		$md5password = md5($password);
 		return $md5password;	
 	}
 	
 	public function login($username, $password){
 		if(empty($username)){
 			displayError(ERROR_NOUSERNAME);	
 		}
 		if(empty($password)){
 			displayError(ERROR_NOPASSWORD);	
 		}
 	}
 	
 	public function showLoginForm(){
 		global $form;
 		$LoginForm = $form->open("login");
 		$LoginForm .= $form->input("username", "username");
 		$LoginForm .= $form->input("password", "password", "password");
 		$LoginForm .= $form->input("login", "submit", "submit");
 		$LoginForm .= $form->close();
 		
 		return $LoginForm;	
 	}
 	
 }
?>